//package com.jiezhuo.config.mybatis;
//
//import com.baomidou.mybatisplus.core.MybatisConfiguration;
//import com.baomidou.mybatisplus.core.MybatisXMLLanguageDriver;
//import com.baomidou.mybatisplus.core.config.GlobalConfig;
//import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
//import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
//import org.apache.ibatis.logging.stdout.StdOutImpl;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.apache.ibatis.type.JdbcType;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//
//import javax.annotation.Resource;
//import javax.sql.DataSource;
//
//@Configuration
//@MapperScan(basePackages = {"com.jiezhuo.mapper.iot"}, sqlSessionFactoryRef = "sqlSessionFactoryIot")
//public class IotConfig {
//    @Autowired
//    MybatisPlusInterceptor mybatisPlusInterceptor;
//    @Resource
//    @Qualifier("iotDb")
//    private DataSource iot;
//
//    @Bean(name = "sqlSessionFactoryIot")
////    @Primary
//    public SqlSessionFactory sqlSessionFactoryIot() throws Exception {
//        MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
//        sqlSessionFactory.setDataSource(iot);
//        MybatisConfiguration configuration = new MybatisConfiguration();
//        configuration.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
//        configuration.setJdbcTypeForNull(JdbcType.NULL);
//        configuration.setLogImpl(StdOutImpl.class);
//        sqlSessionFactory.setConfiguration(configuration);
//        sqlSessionFactory.setPlugins(mybatisPlusInterceptor);
//        sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().
//                getResources("classpath*:com/jiezhuo/mapper/**/*.xml"));
//        sqlSessionFactory.setGlobalConfig(new GlobalConfig().setBanner(false));
//        sqlSessionFactory.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
//        return sqlSessionFactory.getObject();
//    }
//
//
//    @Bean(name = "IotTransactionManager")
//    public DataSourceTransactionManager ds2TransactionManager() {
//        return new DataSourceTransactionManager(iot);
//    }
//
//    @Bean
////    @Primary
//    public SqlSessionTemplate sqlSessionTemplateIot() throws Exception {
//        SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactoryIot());
//        return sqlSessionTemplate;
//    }
//}
